import * as _ from 'lodash'


export const  deepClone = ( arg: any ):any =>{  return _.cloneDeep(arg) }

// 防抖
function debounce(fn: () => void, wait: number): () => void {
  let timeout: NodeJS.Timeout | null = null;
  return async () => {
    if (timeout !== null) {
      clearTimeout(timeout);
    }
    timeout = setTimeout(() => {
      fn();
    }, wait);
  };
}

// 节流
export function throttle(fn: () => void, wait: number): () => void {
  let timeout: NodeJS.Timeout | null = null;
  return async () => {
    if (timeout !== null) {
      clearTimeout(timeout);
    }
    timeout = setTimeout(() => {
      fn();
    }, wait);
  };
}

//